package com.ruimei.util;

import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FileUtils;
import org.springframework.web.multipart.MultipartFile;

public class MultToFile
{
  public static File analyzeFile(MultipartFile file, HttpServletRequest request)
  {
    File tempFile = null;
    if (!file.isEmpty())
    {
      String filePath = request.getSession().getServletContext().getRealPath("/") + "upload/";
      File dir = new File(filePath);
      if (!dir.exists()) {
        dir.mkdir();
      }
      String path = filePath + file.getOriginalFilename();
      try
      {
        tempFile = new File(path);
        FileUtils.copyInputStreamToFile(file.getInputStream(), tempFile);
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
    }
    return tempFile;
  }
}


/* Location:              E:\360MoveData\Users\admin\Desktop\teacher_wap-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes\com\ruime\\util\MultToFile.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */